<extend name="Public/base"/>

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>{$title}</h2>
    </div>
	<div class="cf">
		<div class="fl tools">
				<if condition="$add_button"><php> $add_url || $add_url = U('add?model='.$model['id']);</php><a class="btn" href="{$add_url}">新 增</a></if>
				<if condition="$del_button"><php> $del_url || $del_url = U('del?model='.$model['id']);</php><button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">删 除</button></if>
				<a class="btn" href="{:U('Api/Index/index')}" target='_blank'>API说明手册</a>
		</div>
		<!-- 高级搜索 -->
        <if condition="$search_button">
		<div class="search-form fr cf">
			<div class="sleft">
            <php> $get_param['model']=$model['name']; $search_url || $search_url = U(MODULE_NAME.'/'.CONTROLLER_NAME.'/lists', $get_param);</php>
                <php>empty($search_key) && isset($model['search_key']) && $search_key=$model['search_key'];empty($search_key) && $search_key='title';</php>
				<input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}" placeholder="{$placeholder}">
				<a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a>
			</div>

		</div>
        </if>
	</div>


    <!-- 数据列表 -->
      <php>$now_by = I('by','asc'); if($now_by=='asc'){ $next_by = 'desc'; $by_icon = '（正序）'; } else { $next_by = 'asc'; $by_icon = '（倒序）'; }</php>
    <div class="data-table">
        <div class="data-table table-striped">
            <table>
                <!-- 表头 -->
                <thead>
                    <tr>
                        <if condition="$check_all"><th class="row-selected row-selected">
                            <input autocomplete="off" class="check-all" type="checkbox">
                        </th></if>
                        <volist name="list_grids" id="field">
                  <th <notempty name="field.width">style="width:{$field.width}px"</notempty> >
                  <notempty name="field.is_sort">
                  <php>
                  $get_param['order'] = $field['name'];
                  $get_param['by'] = $next_by; 
                  $show_by = ''; 
                  $now_order = I('order'); 
                  if($now_order==$field['name']){
                     $show_by = $by_icon;
                  }
                  $order_url = U(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME, $get_param);
                  </php>
                  <a href="{$order_url}" class="desc">{$field.title} {$show_by}</a>
                  <else />{$field.title}
                  </notempty></th>
                        </volist>
                    </tr>
                </thead>

                <!-- 列表 -->
                <tbody>
                    <volist name="list_data" id="data">
                        <tr>
                  <if condition="$check_all"><td><input autocomplete="off" class="ids regular-checkbox" type="checkbox" value="{$data['id']}" name="ids[]" id="check_{$data['id']}"><label for="check_{$data['id']}"></label></td></if>
                            <volist name="list_grids" id="grid">
                                <td>{$data[$key]}</td>
                            </volist>
                        </tr>
                    </volist>
                </tbody>
            </table>
        </div>
    </div>
    <div class="page">
        {$_page|default=''}
    </div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
	//搜索功能
  $("#search").click(function(){
    var url = $(this).attr('url');
    var str = $('.search-input').val()
        var query  = $('.search-input').attr('name')+'='+str.replace(/(^\s*)|(\s*$)/g,"");

        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
    window.location.href = url;
  }); 

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

})
</script>
</block>
